/*
 * Created by SharpDevelop.
 * User: lovepro
 * Date: 2008-7-28
 * Time: 13:33
 * 
 * To change this template use Tools | Options | Coding | Edit Standard Headers.
 */
using System;
//using System.Exception;

namespace MyStatic
{
	public class MyClass1
	{
		static void Main()
		{
			MyClass2 a = new MyClass2();
			MyClass2 b = new MyClass2();
			a.PrintVar("a");
			b.PrintVar("b");
			
			a.Inc("a");
			a.PrintVar("a");
			b.PrintVar("b");
			
			MyClass2.i = 12;
			Console.WriteLine("Set various i's value from class.");
			a.PrintVar("a");
			b.PrintVar("b");
			
			//MyClass2.s = "I want change the const string.";
			a.Change("a");
			
		}
	}
	
	public class MyClass2
	{
		public static int i = 0;
		public const string s = "My Name Is John.";
		
		public void Inc(string ss)
		{
			i++;
			Console.WriteLine("Inc various i from "+ss);
		}
		
		public void Change(string ss)
		{
			try{
				//s = ss;
				;
			}
			catch(System.Exception e)
			{
				Console.WriteLine(e.Message);
			}
			finally
			{
				Console.WriteLine("Now the const string is "+MyClass2.s);
			}
		}
		
		public void PrintVar(string ss)
		{
			Console.WriteLine("In instance ["+ss+"]");
			Console.WriteLine("Var i = {0}", i);
			Console.WriteLine("The const string is: " + s);
			Console.Write("\n");
		}
	}
}
